home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10293 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: newsroom.hitc.com!usenet
  2. From: psand@eos.hitc.com (G. Patrick Sand)
  3. Newsgroups: gnu.g++.help,comp.lang.c++
  4. Subject: Re: IS THIS LEGAL? Static method returns pointer to class
  5. Date: 6 Mar 1996 19:56:37 GMT
  6. Organization: Hughes Aircraft (EOSDIS)
  7. Message-ID: <4hkqll$o96@newsroom.hitc.com>
  8. References: <4hdu70$efa@panix.com> <Dnt85t.FGu@doc.ntu.ac.uk>
  9. NNTP-Posting-Host: 155.157.118.56
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.99.3
  12.  
  13. In article <Dnt85t.FGu@doc.ntu.ac.uk>, pt3chaj says...
  14. [SNIP!!]
  15. >     17     static Triangle *makeinstance(Param &);
  16. [snip!--a smaller snip ;-))
  17.  
  18. Drop the * before the function name--what you have here is a pointer to a 
  19. function (which is itself a pointer...)
  20.  
  21. It should work fine if you just define it at:
  22.  
  23.     static Triangle makeinstance(Param &);
  24.  
  25. I've used static functions to create objects, especially singletons, a la 
  26. Design Patterns--Gamma, et al.
  27.  
  28. Works like a charm...
  29. -- 
  30. G. Patrick Sand
  31. psand@eos.hitc.com
  32. PatSand@aol.com
  33. (301) 925-0791
  34. "Travel Light But Right..."
  35. Microsoft Network is prohibited from redistributing 
  36. this work in any form, in whole or in part.   License 
  37. to distribute this individual post is available to Microsoft
  38. for $999. Posting without permission constitutes an 
  39. agreement to these terms...gps
  40.  
  41.